import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import legacy from '@vitejs/plugin-legacy'
import vue2 from '@vitejs/plugin-vue2'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue2(),
    legacy({
      targets: ['ie >= 11'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    port: 8282,
    host: '0.0.0.0',
    open: false,
    cors: true,
    strictPort: true,
    proxy: {},
  },
  build: {
    target: 'es2015',
    outDir: `dist-h5`,
    assetsDir: 'assets',
    minify: 'esbuild',
    chunkSizeWarningLimit: 1500,
    cssCodeSplit: true,
    sourcemap: false,
  },
})
